cmake_minimum_required(VERSION 3.26)
project(test)
include_directories(${BOLTDB_SRC_INCLUDE_DIR}
${BOLTDB_THIRD_PARTY_INCLUDE_DIR})

#旧的测试用例
# add_executable(TEST_LRU_REPLACER test_lru_replace.cpp)
# add_test(NAME lru_replacer COMMAND $<TARGET_FILE:TEST_LRU_REPLACER>)
# # target_include_directories(TEST_LRU_REPLACER PUBLIC )
# target_link_libraries(TEST_LRU_REPLACER PUBLIC boltDB gtest gmock_main)

#更加通用的测试用例
file(GLOB TEST_SOURCES "${PROJECT_SOURCE_DIR}/test_*.cpp")
message(STATUS "TEST_SOURCES: ${TEST_SOURCES}")
foreach (test_target_file ${TEST_SOURCES})
    # 生成测试用例名
    message(STATUS "test_target_file: ${test_target_file}")
    get_filename_component(test_target_filename ${test_target_file} NAME)
    string(REPLACE ".cpp" "" test_target_name ${test_target_filename})
    string(TOUPPER "${test_target_name}" uppercase_test_target_name)
    message(STATUS "uppercase_test_target_name: ${uppercase_test_target_name}")
    # 加入测试
    add_executable(${uppercase_test_target_name} ${test_target_file})
    add_test(NAME ${uppercase_test_target_name} COMMAND $<TARGET_FILE:${uppercase_test_target_name}>)
    target_link_libraries(${uppercase_test_target_name} PUBLIC boltDB gtest gmock_main)   
endforeach ()

